package com.fileshare.web.dto.Vo;

import com.fileshare.web.entity.FileResource;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class FileResourceVo {
    private String name;
    private String fileLocation;
    private String fileSeq;
    private String description;
    private String referenceSeq;
    private String md5Value;
    private Date createAt;

    public static FileResourceVo fromEntity(FileResource resource) {
        FileResourceVo fileResourceVo = new FileResourceVo();
        BeanUtils.copyProperties(resource, fileResourceVo);
        return fileResourceVo;
    }

    public static List<FileResourceVo> fromEntities(List<FileResource> resources) {
        return resources.stream().map(FileResourceVo::fromEntity).collect(Collectors.toList());
    }
}
